<!-- 卡通图 -->
<template>
	<page-meta :root-font-size="getRootFontSize()"></page-meta>	
	<view class="">
		<view class="topBox">
			<view class="status_bar"></view>
			<uni-nav-bar
				style="width: 750rpx; height: 44px;"
				@clickRight="showSetUp"
				@clickLeft="goHome"
				color="#FDFDFD"
				:border="false"
				:shadow="false"
				background-color="#F1F1F1"
			>
				<view class="titleImg"><image style="width: 100%; height: 100%;" mode="scaleToFill" src="/static/icon/logo_ctw@3x.png"></image></view>
				<view slot="left">
					<view class="leftIconBox"><uni-icons type="arrowleft" color="#000" size="18"></uni-icons></view>
				</view>
				<view slot="right"><uni-icons type="bars" color="#7F7F7F" size="28"></uni-icons></view>
			</uni-nav-bar>
		</view>
		<view class="zhuti" :style="{ marginTop: topBar }">
			<view class="imageTopBox"><image style="width: 100%; height: 100%;" mode="scaleToFill" src="/static/icon/AboutUs/2x/pic_banner@2x.png"></image></view>
			<view class="tabTopBox">
				<view class="tabTopBoxL">{{i18n.ctwfont0}}</view>
				<view class="tabTopBoxRText">
					{{i18n.ctwfont1}}
				</view>
			</view>
			<!-- 内容 -->
			<view class="neironBox">
				<view class="neironBoxImg"><image style="width: 100%; height: 100%;" mode="scaleToFill" src="/static/icon/AboutUs/2x/AboutUs6@2x.png"></image></view>
				<view class="tabTopBoxRText" style="margin-bottom: 10px;">
					{{i18n.ctwfont2}}
				</view>
				<view class="neironBoxText">{{i18n.ctwfont3}}</view>
				<view class="neironBoxTitle">{{i18n.ctwfont4}}</view>
				<view class="neironBoxTitle">{{i18n.ctwfont5}}</view>
				<view class="neironBoxTitle">{{i18n.ctwfont6}}</view>
				<view class="neironBoxTitle">{{i18n.ctwfont17}}</view>
				<view class="neironBoxTitle">{{i18n.ctwfont7}}</view>
				<view class="neironBoxTitle">{{i18n.ctwfont8}}</view>
				<view class="neironBoxTitle">{{i18n.ctwfont9}}</view>
				<view class="neironBoxTitle">{{i18n.ctwfont10}}</view>
				<view class="neironBoxTitle">{{i18n.ctwfont11}}</view>
				<view class="neironBoxTitle">{{i18n.ctwfont12}}</view>
				<view class="neironBoxTitle">{{i18n.ctwfont13}}</view>
			</view>
			<view class="zhoImg"><image style="width: 100%; height: 100%;" mode="scaleToFill" src="/static/icon/AboutUs/2x/AboutUs7@2x.png"></image></view>
			<view class="neironBox bottomBoxss">
				<view class="tabTopBoxRText">{{i18n.ctwfont14}}</view>
				<view class="neironBoxTitle" style="margin: 5px 0;">{{i18n.ctwfont15}}</view>
				<view class="neironBoxText">{{i18n.ctwfont16}}</view>
			</view>
		</view>
		<!-- 设置 -->
		<uni-popup ref="SetUpPopup" type="center" :animation="false"><set-up-pages ref="showPopup" @closePopUp="closePopUp" /></uni-popup>
		<!-- 退出 -->
		<sign-out ref="signOutBox" />
		<!-- 底部菜单 -->
		<bottom-pages></bottom-pages>
	</view>
</template>

<script>
import setUpPages from '@/pages/setUpPages/index.vue';
import signOut from '@/pages/setUpPages/signOut.vue'; // 退出登录
import bottomPages from '@/pages/home/bottomPages.vue'; // 底部
import baseFont from '@/utils/baseFont.js';
export default {
	extends: baseFont,
	data: function() {
		return {
			topBarHeight: 0,
			windowHeight: 0,
			back_k: 0, // 物理返回
			popupIsShow: false, // 打开设置的标识
			signOutShow: false // 退出登录
		};
	},
	onLoad() {
		// 拦截物理返回键
		this.goBackBox();
	},
	onUnload() {
		uni.$off('goBack_k', this.goBackBox2);
	},
	onHide() {
		if (this.$refs.SetUpPopup) {
			this.$refs.SetUpPopup.close();
		}
		if (this.$refs.signOutBox) {
			this.$refs.signOutBox.close();
		}
		this.popupIsShow = false;
	},
	created() {
		const that = this;
		uni.getSystemInfo({
			success(res) {
				that.topBarHeight = res.statusBarHeight;
				that.windowHeight = res.windowHeight;
			}
		});
	},
	components: { setUpPages, signOut, bottomPages },
	computed: {
		topBar() {
			let num = 0;
			num = this.topBarHeight + 44; // 44是顶部高度
			return num + 'px';
		},
		i18n() {
			return this.$t('AboutUs');
		}
	},
	methods: {
		goBackBox() {
			// const that = this;
			uni.$on('goBack_k', this.goBackBox2);
		},
		goBackBox2(data) {
			this.back_k < 0 ? (this.back_k = 0) : (this.back_k = this.back_k);
			if (data) {
				if (this.popupIsShow) {
					this.$refs.SetUpPopup.close();
					this.popupIsShow = false;
				} else if (this.signOutShow) {
					this.$refs.signOutBox.close();
					this.signOutShow = false;
				} else {
					let main = plus.android.runtimeMainActivity();
					if (this.back_k > 0) {
						this.back_k = 0;
						return main.moveTaskToBack(false);
						// return plus.runtime.quit();
					} else {
						const pages = getCurrentPages();
						if (pages.length === 1) {
							this.back_k++;
							setTimeout(() => {
								this.back_k--;
							}, 1000);
							// #ifdef APP-PLUS
							uni.redirectTo({
								url: '/pages/home/index'
							});
							// #endif
							// #ifdef H5
							this.$Router.push('/pages/home/index');
							// #endif
							// uni.showToast({
							// 	title: '再按一次退出应用',
							// 	icon: 'none',
							// 	duration: 1000
							// });
						}
					}
				}
			}
		},
		// 返回home
		goHome() {
			// #ifdef APP-PLUS
			uni.redirectTo({
				url: '/pages/home/index'
			});
			// #endif
			// #ifdef H5
			this.$Router.push('/pages/home/index');
			// #endif
		},
		// 打开设置
		showSetUp() {
			this.$refs.SetUpPopup.open('right');
			this.popupIsShow = true;
		},
		// 关闭设置
		closePopUp(val) {
			if (val) {
				this.$refs.SetUpPopup.close();
				this.popupIsShow = false;
			} else {
				this.$refs.SetUpPopup.close();
				this.popupIsShow = false;
				this.$refs.signOutBox.open();
				this.signOutShow = true;
			}
		}
	}
};
</script>

<style lang="scss" scoped>
.titleImg {
	width: 60px;
	height: 30px;
	margin: 0 auto;
	border-radius: 50%;
	overflow: hidden;
}
.leftIconBox {
	width: 25px;
	height: 25px;
	background-color: #fff;
	border-radius: 50%;
	display: flex;
	justify-content: center;
	align-items: center;
	margin-left: 15px;
}
.topBox {
	position: fixed;
	top: 0;
	left: 0;
	z-index: 10;
	// 顶部部分
	.status_bar {
		height: var(--status-bar-height);
		background-color: #f1f1f1;
		width: 100%;
	}
}
.zhuti {
	.imageTopBox {
		width: 100%;
		height: 100px;
	}
	.tabTopBoxRText {
		font-size: $uni-font-size-custom-b;
		line-height: 16px;
		color: #484a56;
		word-break: break-all; // 强制换行
	}
	.tabTopBox {
		padding: 16px 20px;
		// height: 40px;
		// line-height: 40px;
		box-sizing: border-box;
		.tabTopBoxL {
			color: #CD001B;
			font-size: $uni-font-size-custom-e;
			font-weight: 700;
		}
	}
	.neironBox {
		width: 100%;
		padding: 15px;
		box-sizing: border-box;
		background-color: #f1f1f1;
		.neironBoxImg {
			width: 70%;
			height: 240px;
			margin: 0 auto;
			padding-bottom: 10px;
		}
		.neironBoxTitle {
			font-size: $uni-font-size-custom-b;
			font-weight: 700;
			line-height: 15px;
			color: #484a56;
			margin-top: 10px;
			word-break: break-all; // 强制换行
		}
		.neironBoxText {
			font-size: $uni-font-size-custom-b;
			line-height: 15px;
			color: #424451;
			font-weight: 700px;
			word-break: break-all; // 强制换行
		}
	}
	.zhoImg {
		width: 100%;
		height: 240px;
	}

	.bottomBoxss {
		box-shadow: 0 3px 5px 1px #e6e6e6;
		margin-bottom: 40px;
	}
}
</style>
